﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;

namespace DataAccess
{
    public class InfoGiaoVien
    {
        private string _MaGV;

        public string MaGV
        {
            get { return _MaGV; }
            set { _MaGV = value; }
        }
        private string _HoTenGV;

        public string HoTenGV
        {
            get { return _HoTenGV; }
            set { _HoTenGV = value; }
        }
        private string _GioiTinh;

        public string GioiTinh
        {
            get { return _GioiTinh; }
            set { _GioiTinh = value; }
        }

        private DateTime _NgaySinh;
        
        public DateTime NgaySinh
        {
            get { return _NgaySinh; }
            set { _NgaySinh = value; }
        }

        private string _SoDT;

        public string SoDT
        {
            get { return _SoDT; }
            set { _SoDT = value; }
        }
        private string _Email;

        public string Email
        {
            get { return _Email; }
            set { _Email = value; }
        }
        private string _DiaChi;

        public string DiaChi
        {
            get { return _DiaChi; }
            set { _DiaChi = value; }
        }
        private string _TrinhDo;

        public string TrinhDo
        {
            get { return _TrinhDo; }
            set { _TrinhDo = value; }
        }
   
        public InfoGiaoVien()
        { }
        //Xuat tat ca cac thong tin cua giao vien
        public static List<InfoGiaoVien> DanhSachGiaoVien()
        {
            return CBO.FillCollection<InfoGiaoVien>(DataProvider.Instance.ExecuteReader("GiaoVien_Select"));
        }
        //Them mot giao vien
        public static int AddGiaoVien(InfoGiaoVien infogiaovien)
        {
            return DataProvider.Instance.ExecuteNonQuery("GiaoVien_Add", infogiaovien.MaGV, infogiaovien.HoTenGV, infogiaovien.GioiTinh, infogiaovien.NgaySinh, infogiaovien.SoDT, infogiaovien.Email, infogiaovien.DiaChi, infogiaovien.TrinhDo);
        }
        // Xoa mot giao vien
        public static int DeleteGiaoVien(string delete)
        {
            return DataProvider.Instance.ExecuteNonQuery("GiaoVien_Delete", delete);
        }
        //Update mot giao vien
        public static int UpdateGiaoVien(InfoGiaoVien infogiaovien)
        {
            return DataProvider.Instance.ExecuteNonQuery("GiaoVien_Update", infogiaovien.MaGV, infogiaovien.HoTenGV, infogiaovien.GioiTinh, infogiaovien.NgaySinh, infogiaovien.SoDT, infogiaovien.Email, infogiaovien.DiaChi, infogiaovien.TrinhDo);
        }
        // Tim kiem theo ma giao vien
        public static List<InfoGiaoVien> TimKiemTheoMaGV(string ma)
        {
            return CBO.FillCollection<InfoGiaoVien>(DataProvider.Instance.ExecuteReader("GiaoVien_TimKiemMa", ma));
        }
        //Tim kiem theo ho ten
        public static List<InfoGiaoVien> TimKiemTheoHoTenGV(string hoten)
        {
            return CBO.FillCollection<InfoGiaoVien>(DataProvider.Instance.ExecuteReader("GiaoVien_TimKiemHoTen", hoten));
        }
        //Tim kiem theo dia chi
        public static List<InfoGiaoVien> TimKiemTheoDiaChiGV(string diachi)
        {
            return CBO.FillCollection<InfoGiaoVien>(DataProvider.Instance.ExecuteReader("GiaoVien_TimKiemTrinhDo", diachi));
        }


        // Thong ke so luong gia vien theo ma
        public static int ThongKeTheoMaGV()
        {
            object result = DataProvider.Instance.ExecuteScalar("GiaoVien_ThongKeMa");
            return Convert.ToInt32(result);
        }
        //Thong ke theo ho ten
        public static int ThongKeTheoHoTenGV(string hoten)
        {
            object result = DataProvider.Instance.ExecuteScalar("GiaoVien_ThongKeHoTen", hoten);
            return Convert.ToInt32(result);
        }
        //Thong ke theo dia chi
        public static int ThongKeTheoDiaChiGV(string diachi)
        {
            object result = DataProvider.Instance.ExecuteScalar("GiaoVien_ThongKeTrinhDo", diachi);
            return Convert.ToInt32(result);
        }
    }
}
